package cn.net.sinodata.system.msghandler.parse.dto;

public class ParseResult<T> {
    private int code;
    private String codeDesc;
    private T data;

    public ParseResult() {
    }

    public ParseResult(int code, String codeDesc, T data) {
        this.code = code;
        this.codeDesc = codeDesc;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getCodeDesc() {
        return codeDesc;
    }

    public void setCodeDesc(String codeDesc) {
        this.codeDesc = codeDesc;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static ParseResult fail(String codeDesc) {
        ParseResult parseResult = new ParseResult();
        parseResult.setCode(-1);
        parseResult.setCodeDesc(codeDesc);
        return parseResult;
    }

    public static <T> ParseResult success(T data) {
        ParseResult parseResult = new ParseResult();
        parseResult.setCode(0);
        parseResult.setData(data);
        return parseResult;
    }
}
